package com.hiyee.typeHandler;

import com.hiyee.utils.JsonUtil;
import org.apache.ibatis.type.*;

import java.sql.*;
import java.util.List;

/**
 * Json 字符串转 List<String>
 *
 * @author WangBin
 */
public class ArrayTypeHandler extends BaseTypeHandler<List<String>> {

    @Override
    public void setNonNullParameter(PreparedStatement preparedStatement, int i, List<String> strings, JdbcType jdbcType) throws SQLException {

    }

    @Override
    public List<String> getNullableResult(ResultSet resultSet, String s) throws SQLException {
        String json = resultSet.getString(s);
        return JsonUtil.jsonToList(json, String.class);
    }

    @Override
    public List<String> getNullableResult(ResultSet resultSet, int i) throws SQLException {
        return null;
    }

    @Override
    public List<String> getNullableResult(CallableStatement callableStatement, int i) throws SQLException {
        return null;
    }
}
